package main

import (
	"fmt"
	"github.com/gin-gonic/gin"
)

func main() {
	r.GET("/test", func(c *gin.Context) {
		// 获取基本请求信息
		fmt.Println(c.Request.Method)     // GET
		fmt.Println(c.Request.URL)        // /test
		fmt.Println(c.Request.RemoteAddr) // 127.0.0.1:58581
		fmt.Println(c.ClientIP())         // 127.0.0.1
		// 获取请求头
		fmt.Println(c.Request.Header)
		fmt.Println(c.Request.Header["User-Agent"])
		fmt.Println(c.GetHeader("User-Agent"))

		c.String(200, "test OK!")

	})
}
